/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package bibsys;

import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.File;
import java.io.FileReader;
import java.io.FileWriter;
import java.io.IOException;

/**
 *
 * @author Nati
 */
public class Salvar {

    private Salvar() {
    }

    public static boolean salvar(String path, StringBuffer buf) {
        boolean b = false;
        try {
            File file = new File(path);
            if (!file.exists()) {
                file.createNewFile();
            }
            FileWriter fw = new FileWriter(file.getAbsoluteFile());
            BufferedWriter bw = new BufferedWriter(fw);
            bw.write(buf.toString());
            bw.close();
            b = true;
            return b;
        } catch (IOException ex) {
            System.out.println("Erro: Mensagem: \n" + ex.getMessage());
            return b;
        }
    }
/*
    public static void main(String[] args) {
        String st;
        st = "teste";
        salvar("C:\\Users\\Nati\\Desktop\\teste.bib", st);
    }*/
}